<template>
    <div class="photo-container">
        <!-- 顶部滑动条 -->
        <div id="slider" class="mui-slider">
            <div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
                <div class="mui-scroll">
                    <a :class="['mui-control-item', item.id==0?'mui-active':'']" v-for="item in newslist" :key="item.id" @tap="getphotoById(item.id)">
                        {{ item.name }}
                    </a>
                </div>
            </div>
        </div>
        <!-- 图片列表区域 -->
        <ul class="photo-list">
            <router-link v-for="item in list" :key="item.id" :to="'/home/photoinfo/'+item.id" tag="li">
                <img v-lazy="item.img">
                <div class="info">
                    <h1 class="title">{{ item.name }} --- {{ item.date }}</h1>
                    <div class="body">{{ item.count }}</div>
                    
                </div>
            </router-link>
        </ul>
    </div>
</template>

<script>
import mui from '../../lib/mui/js/mui.min.js'
import { Toast } from 'mint-ui'

export default {
    data(){
        return{
            newslist: [], // 新闻资讯列表
            list: []
        }
    },
    methods: {
        getphotoById(flid){ // 根据分类获取图标
            this.list = []
            var listArr = [
                { id:'1', name: '家居生活', date: '2019-09-08', count: '寿比南山近段时间很简单和附近的是否滑稽的是符号位', img: '../../images/1.gif'},
                { id:'2', name: '摄影设计', date: '2019-09-09', count: '寿比南山近段时间很简单和附近的是否滑稽的是符号位', img: '../../images/2.gif'},
                { id:'3', name: '明星美女', date: '2019-09-10', count: '寿比南山近段时间很简单和附近的是否滑稽的是符号位', img: '../../images/3.gif'},
                { id:'4', name: '摄影器材', date: '2019-09-10', count: '寿比南山近段时间很简单和附近的是否滑稽的是符号位', img: '../../images/10.gif'},
                { id:'5', name: '明星写真', date: '2019-09-10', count: '寿比南山近段时间很简单和附近的是否滑稽的是符号位', img: '../../images/17.gif'},
                { id:'6', name: '古典美女', date: '2019-09-10', count: '寿比南山近段时间很简单和附近的是否滑稽的是符号位', img: '../../images/19.gif'},
                { id:'7', name: '影视推荐', date: '2019-09-10', count: '寿比南山近段时间很简单和附近的是否滑稽的是符号位', img: '../../images/32.gif'},
                { id:'8', name: '魔性的小哪吒', date: '2019-09-10', count: '好的恢复时间合法的身份随活动方式负担很多思考和地方就是和实际花费的时间和长时间的环境是否和回家的时候覅活动方式回复的技术开发是假的回复和发动机是防水等级划分发货的首付多少积分函数粉红色都会发生的纠纷还是', img: '../../images/0.jpg'},
                { id:'9', name: '搞笑视频', date: '2019-09-10', count: '蛤加分哥哥股东会决定给啥的啥的干哈大噶数据库的嘎就开始大数据的凯撒就见到过撒娇多久啊是大蒜价格的哈桑更多', img: '../../images/4.png'},
                { id:'10', name: '搞笑视频', date: '2019-09-10', count: '321', img: '../../images/5.jpg'},
                { id:'11', name: '搞笑视频', date: '2019-09-10', count: '321', img: '../../images/6.jpg'},
                { id:'12', name: '搞笑视频', date: '2019-09-10', count: '321', img: '../../images/7.jpg'},
                { id:'13', name: '搞笑视频', date: '2019-09-10', count: '321', img: '../../images/8.jpg'},
                { id:'14', name: '搞笑视频', date: '2019-09-10', count: '321', img: '../../images/18.jpg'},
                { id:'15', name: '搞笑视频', date: '2019-09-10', count: '321', img: '../../images/20.jpg'},
                { id:'16', name: '搞笑视频', date: '2019-09-10', count: '321', img: '../../images/21.jpg'},
                { id:'17', name: '搞笑视频', date: '2019-09-10', count: '321', img: '../../images/22.jpg'},
                { id:'18', name: '搞笑视频', date: '2019-09-10', count: '321', img: '../../images/23.jpg'},
            ]
             if(flid == 0){
                 this.list = listArr
             }else if(flid == 1){
                 for(var i=0;i<7;i++){
                     this.list.push(listArr[i])
                 }

             }else if(flid == 2){
                 for(var i=7;i<13;i++){
                     this.list.push(listArr[i])
                 }

             }else if(flid == 3){
                 for(var i=13;i<18;i++){
                     this.list.push(listArr[i])
                 }

             }

        },
        getPhotosList(){
            var list = [
                { id:'1', name: '家居生活'},
                { id:'2', name: '摄影设计'},
                { id:'3', name: '明星美女'},
                { id:'4', name: '摄影器材'},
                { id:'5', name: '明星写真'},
                { id:'6', name: '古典美女'},
                { id:'7', name: '影视推荐'},
                { id:'8', name: '搞笑视频'},
            ]
            this.newslist = list
            this.newslist.unshift({name: '全部', id: '0'})
        }
    },
    mounted(){  // 当组件中的 demo 结构被渲染好，并放到页面中，才执行这个 钩子函数
        // 初始化 滑动控件
        mui('.mui-scroll-wrapper').scroll({
            deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
        });
       
    },
    created(){
        this.getPhotosList()
        this.getphotoById('0')
    }
    
}
</script>

<style lang="scss" scoped>
.photo-list{
    list-style: none;
    margin: 0;
    padding: 10px;
    padding-bottom: 10px;

    li{
        background-color: #ccc;
        text-align: center;
        margin-bottom: 10px;
        box-shadow: 0 0 6px #999;
        position: relative;
        img{
            width: 100%;
            vertical-align: middle;
        }
        img[lazy=loading] {
            width: 40px;
            height: 300px;
            margin: auto;
        }

        .info{
            color:white;
            text-align: left;
            position: absolute;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.4);
            width: 100%;
            max-height: 84px;
            .title{
                font-size: 14px;
            }
            .body{
                font-size: 13px;
            }
        }
    }
}
 * { touch-action: pan-y; }
 


</style>